package net.sansi.v3correctserver.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sansi.v3correctserver.dto.R;
import net.sansi.v3correctserver.dto.app.AppDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Fang
 * create time : 2024/11/5
 * IDE : IntelliJ IDEA
 */
@Api(tags = "APP相关接口")
@RestController
@RequestMapping("/app")
@Validated
public class AppController {

    @Value("${app.version}")
    private String appVersion;

    /**
     * app 信息(版本等）
     *
     * @return app 信息
     */
    @ApiOperation("app 信息")
    @GetMapping("/info")
    public R<AppDto.InfoResp> info() {
        AppDto.InfoResp res = new AppDto.InfoResp();
        res.setVersion(appVersion);
        return R.data(res);
    }

    /**
     * 保活API, 固定返回 PONG
     *
     * @return PONG
     */
    @ApiOperation("保活API, 固定返回 PONG")
    @GetMapping("/PING")
    public R<String> keepAlive() {
        return R.data("PONG");
    }

}
